package com.vibration.web.controller.baseinfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.vibration.baseinfo.domain.CzTemperatureData;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vibration.common.annotation.Log;
import com.vibration.common.core.controller.BaseController;
import com.vibration.common.core.domain.AjaxResult;
import com.vibration.common.enums.BusinessType;
import com.vibration.baseinfo.domain.CzGyroscopeData;
import com.vibration.baseinfo.service.ICzGyroscopeDataService;
import com.vibration.common.utils.poi.ExcelUtil;
import com.vibration.common.core.page.TableDataInfo;

/**
 * 陀螺仪数据Controller
 * 
 * @author wu
 * @date 2022-08-11
 */
@RestController
@RequestMapping("/baseinfo/gyroscopeData")
public class CzGyroscopeDataController extends BaseController
{
    @Autowired
    private ICzGyroscopeDataService czGyroscopeDataService;

    /**
     * 查询陀螺仪数据列表
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:gyroscopeData:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzGyroscopeData czGyroscopeData)
    {
        startPage();
        List<CzGyroscopeData> list = czGyroscopeDataService.selectCzGyroscopeDataList(czGyroscopeData);
        return getDataTable(list);
    }


    @GetMapping(value = "/getGyroscopeData/{code}")
    public AjaxResult getGyroscopeData(@PathVariable("code") String code)
    {
        return AjaxResult.success(czGyroscopeDataService.getGyroscopeData(code));
    }

    /**
     * 导出陀螺仪数据列表
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:gyroscopeData:export')")
    @Log(title = "陀螺仪数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzGyroscopeData czGyroscopeData)
    {
        List<CzGyroscopeData> list = czGyroscopeDataService.selectCzGyroscopeDataList(czGyroscopeData);
        ExcelUtil<CzGyroscopeData> util = new ExcelUtil<CzGyroscopeData>(CzGyroscopeData.class);
        util.exportExcel(response, list, "陀螺仪数据数据");
    }

    /**
     * 获取陀螺仪数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:gyroscopeData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(czGyroscopeDataService.selectCzGyroscopeDataById(id));
    }

    /**
     * 新增陀螺仪数据
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:gyroscopeData:add')")
    @Log(title = "陀螺仪数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzGyroscopeData czGyroscopeData)
    {
        return toAjax(czGyroscopeDataService.insertCzGyroscopeData(czGyroscopeData));
    }

    /**
     * 修改陀螺仪数据
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:gyroscopeData:edit')")
    @Log(title = "陀螺仪数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzGyroscopeData czGyroscopeData)
    {
        return toAjax(czGyroscopeDataService.updateCzGyroscopeData(czGyroscopeData));
    }

    /**
     * 删除陀螺仪数据
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:gyroscopeData:remove')")
    @Log(title = "陀螺仪数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(czGyroscopeDataService.deleteCzGyroscopeDataByIds(ids));
    }



    /***
     * 陀螺仪数据统计
     */
    @GetMapping(value = "/gyroscopeChange")
    public AjaxResult taskCount (String gyroscopeCode)
    {
        //震动任务
        List<CzGyroscopeData> tly = czGyroscopeDataService.selectCzGyroscopeDataByCodeOneHour(gyroscopeCode);
        AjaxResult result = AjaxResult.success();
        result.put("tly",tly);
        return result;
    }
}
